<?php
class Meterrate_model extends CI_Model {
	
	private $tbl_data= 'MST_METER_RATE';
	public function __construct()
	{
		parent::__construct();
	}
	function list_all(){
		//$this->db->order_by('id','asc');
		return "SELECT * FROM MST_METER_RATE";
	}
	function get_all(){
		$query="SELECT MRCODE,MRNAME_TH+' ['+MRCODE+']' MRNAME_TH FROM MST_METER_RATE";
		return $this->db->query($query)->result_array();;
	}
	function count_all(){
		return $this->db->count_all($this->tbl_data);
	}
	
	function get_by_id($id){
		$this->db->where('MRCODE', $id);
		return $this->db->get($this->tbl_data)->row();
	 
	}
	function save($item){		
		return $this->db->insert($this->tbl_data, $item);		
	}
	
	function update($item,$id){
		$this->db->where('MRCODE', $id);
		$this->db->update($this->tbl_data, $item);
	}
	
	function delete($id){
		$this->db->where('MRCODE', $id);
		$this->db->delete($this->tbl_data);
	}
}
?>